<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title > Magic Admin Panel</title>
<!--<link rel="shortcut icon" href="images/favicon.ico/" />-->
<!--
<link type="text/css" href="../../function/jqueryui/jquery-ui-1.8.9.custom.css" rel="stylesheet" />	
<link rel="stylesheet" type="text/css" href="../style/binary.css"/>
<link rel="stylesheet" type="text/css" href="../../style/validate.css" />
<link rel="stylesheet" type="text/css" href="../../website/css/jquery.alerts.css" />-->
<?php echo Template::renderCss(); ?>
<!--<script type="text/javascript" src="../../function/jquery.min.js"></script>
<script type="text/javascript" src="../../function/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="../../function/jquery-ui-1.8.9.custom.min.js"></script>
<script type="text/javascript" src="../../function/jquery.validate.pack.js"></script>
<script type="text/javascript" src="../../website/js/jquery.alerts.js"></script>-->
<?php echo Template::renderJs(); ?>
<!--  Autocompletion jquery File -->
<!--<script type='text/javascript' src='../../function/jquery.autocomplete.js'></script>
<link rel="stylesheet" type="text/css" href="../../style/jquery.autocomplete.css" />-->
<!--  End -->
 

<script type="text/javascript">

	
	function checkAll(field) {
		if(!field.length) {
			if(field.checked==true) {
				field.checked=false;
			} else {
				field.checked=true;
			}
		}
		for (i = 0; i <= field.length; i++)
			if(field[i].checked == true) {
				field[i].checked = false;
			} else {
				field[i].checked = true;
		}
	}
	function CalDay(m,y) {
        if(m==01||m==03||m==05||m==07||m==08||m==10||m==12) {
			var dmax = 31;			
			return dmax;	        
		} else if (m==04||m==06||m==09||m==11) {
			var dmax = 30;		
			return dmax;		  
		} else {
			if((y%400==0) || (y%400==0 && y%100!=0)) {
				dmax = 29;			
				return dmax;
			} else {
                  dmax = 28;				
            }
		return dmax;
		}
	}	
</script>
<script>
$(document).ready(function(){
	$( "#tabs" ).tabs();
	$( "#imagetabs" ).tabs();
	$( "#dialog:ui-dialog" ).dialog( "destroy" );
/*-------------- This is the PopUp Dailog Box  Code -------------*/	
	$( "#dialog-form" ).dialog({
		autoOpen: false,
		height: 200,
		width: 650,
		modal: true,
	});
	
	$( "#user-button-new" ).click(function() {
			$( "#dialog-form" ).dialog( "open" );
	});
/*----------------------------- End ------------------------------*/
	
/*-------------- This is the PopUp Dailog Box  Code -------------*/	
	$( "#dialog-form-1" ).dialog({
		autoOpen: false,
		height: 200,
		width: 650,
		modal: true,
	});
	
	$( "#user-button-new-1" ).click(function() {
			$( "#dialog-form-1" ).dialog( "open" );
	});
/*----------------------------- End ------------------------------*/

	$("#contactform").validate();
	
	DateGenerator=function () {
		var interval=$("#interval").attr("value");
		var date1,date2;
		var d = new Date();
		var t_date=parseInt(d.getDate());
		var t_month=parseInt(d.getMonth());
		var t_year=parseInt(<?php echo date("Y");?>);
		
		if(interval == 'today') {
			var date1 = t_month+1 +"/"+ t_date+"/"+t_year;
			var date2 = t_month+1 +"/"+ t_date+"/"+t_year;
		} else if (interval == 'yesterday') {
			var date1 = t_month+1 +"/"+ t_date+"/"+t_year;
			var date2 = t_month+1 +"/"+ (t_date-1)+"/"+t_year;
		} else if (interval == 'thismonth') {
			var month_days=CalDay(t_month+1,t_year);
			var date1 = t_month+1 +"/"+1+"/"+t_year;
			var date2 = t_month+1 +"/"+ month_days+"/"+t_year;
		} else if (interval == 'lastmonth') {
			var month_days=CalDay(t_month,t_year);
			var date1 = t_month +"/"+1+"/"+t_year;
			var date2 = t_month +"/"+ month_days+"/"+t_year;
		} else {
			var date1="";
			var date2="";
			
		}	
		document.getElementById("date2").value=date2;
		document.getElementById("date1").value=date1;
		
	}
	Hide=function(d){
		$("#"+d).slideUp("slow");
		return false;
	}
	Make_IT_check=function (id,act,start) {
		if(act == 1) {
			a='Inactive';
		} else if (act == 2) {
			a='Active';
		} else if (act == 3) {
			a='Delete';
		} 
		var selector_checked = $("input[@id=chk]:checked").length; 
		if (selector_checked == 0) { 
			$('.chk_'+id).attr('checked',true);
			var answer = confirm('Are You Sure You Want To '+a+'?');
   			if (answer){
           		$('#myform').attr('action','control/insert.php?makestatus=1&act='+a+'&start='+start);
				$('#myform').submit();
			} else {
				$('.chk_'+id).removeAttr('checked');
				return false;
			}
		} else { 
			$('.chk_'+id).removeAttr('checked');
			return false;
		}
	}

	MultipleDelete=function(start){
		var selector_checked = $("input[@id=chk]:checked").length; 
		if(selector_checked > 0 ){
			var answer = confirm('Are You Sure You Want To Delete ?');
			if(answer){
				$('#myform').attr('action','control/insert.php?makestatus=1&act=Delete&start='+start);
				$('#myform').submit();
			} else {
			}
		} else {
			jAlert("Please Selected Atleast One item for delete !");
			return false ;
		}
	}
	SAVENNEW=function (table,page,fieldname,id,act,check) {
		var ck;
		if (check==0){
			ck =0;
		} else{
			ck=1;
		}
		$('#contactform').attr('action','control/insert.php?tablename='+table+'&page='+page+'&act='+act+'&check='+ck+'&fieldname='+fieldname+'&id='+id+'&savenew=1');
		$('#contactform').submit();
	}
	GetSubSegment=function() {
		var ids=$("#segment_master_id").attr("value");
		$.ajax({
			type:"POST",
			url:"control/insert.php",
			data:"act=GetSubSegment&id="+ids,
				success: function(msg){
				$("#sub_segment").show("slow");
				document.getElementById('sub_segment').innerHTML = msg;
				//$("#sub_segment").html();	
				
				return false;
			}
		});
	};
	GetProductName=function() {
		var name=$("#segment_name").attr("value");
		$.ajax({
			type:"POST",
			url:"control/insert.php",
			data:"act=GetProductName&segment="+name,
				success: function(msg){
				$("#product_name").show("slow");
				document.getElementById('product_div').innerHTML = msg;
				//$("#sub_segment").html();	
				
				return false;
			}
		});
	};
  //----- delete popular and new realesed ----//
  DellPopRel=function(id,tablename) {
		$.ajax({
			type:"POST",
			url:"control/product_insert.php",
			data:"act=DellPopRel&id="+id+"&tablename="+tablename,
				success: function(msg){
				
				return false;
			}
		});
	};
 // ---- end ----//
	//------------------ dispaly value getsubsegment product -------------//
	GetSubSegmentProduct=function() {
		var ids=$("#segment_master_id").attr("value");
		$.ajax({
			type:"POST",
			url:"control/insert.php",
			data:"act=GetSubSegmentProduct&id="+ids,
				success: function(msg){
				$("#sub_segment").show("slow");
				document.getElementById('sub_segment').innerHTML = msg;
				//$("#sub_segment").html();	
				
				return false;
			}
		});
	};
	//-----------------------end ----------------------------------//
	GetCategory=function() {
		var ids=$("#segment_master_id").attr("value");
		var sids=$("#subsegment_master_id").attr("value");
		
		$.ajax({
			type:"POST",
			url:"control/insert.php",
			data:"act=GetCategory&id="+ids+"&sid="+sids,
				success: function(msg){
				$("#category_div").show("slow");
				document.getElementById('category_div').innerHTML = msg;
				//$("#sub_segment").html();	
				
				GetBrandNTypeNSubcategoy(2,'type_div');
				GetBrandNTypeNSubcategoy(3,'brand_div');
				GetSubCategory();
				return false;
				
			}
		});
	};
	GetSubCategory=function () {
		var id=$("#segment_master_id").attr("value");
		var sid=$("#subsegment_master_id").attr("value");
		var cid=$("#category_master_id").attr("value");
		
		$.ajax({
			type:"POST",
			url:"control/insert.php",
			data:"act=GetsubCategory&id="+id+"&sid="+sid+"&cid="+cid,
				success: function(msg){
				$("#subcategory_div").show("slow");
				document.getElementById('subcategory_div').innerHTML = msg;
				return false;
				
			}
		});
	}
	GetSubCategoryByCategory=function () {	
		var cid=$("#category_master_id").attr("value");
		$.ajax({
			type:"POST",
			url:"control/insert.php",
			data:"act=GetSubCategoryByCategory&cid="+cid,
				success: function(msg){
				$("#subcategory_div").show("slow");
				document.getElementById('subcategory_div').innerHTML = msg;
				return false;
				
			}
		});
	}
	GetBrandNTypeNSubcategoy=function (status,divition) {
		var ids=$("#segment_master_id").attr("value");
		var sids=$("#subsegment_master_id").attr("value");
		
		$.ajax({
			type:"POST",
			url:"control/insert.php",
			data:"act=BandTypeCategory&status="+status+"&id="+ids+"&sid="+sids,
				success: function(msg){
				/*$("#"+divition).show("slow");
				if(status == 1) {
					document.getElementById('subcategory_div').innerHTML = msg;
				} else*/ if(status == 2) {
					document.getElementById('type_div').innerHTML = msg;
				} else if (status == 3) {
					document.getElementById('brand_div').innerHTML = msg;
				}
				return false;
			}
		});	
	}
	MakeDelete=function (table,act,page) {
		var checked = $("input[@id=chk]:checked").length;
			if(checked >0) {
				var answer = confirm('Are You Sure You Want To '+act+'?');
				if(answer) {
					$('#myform').attr('action','control/insert.php?tablename='+table+'&page='+page+'&act='+act+'&makestatus=1');
					$('#myform').submit();
				} else {
					return false;
				}
			} else {
				jAlert("Please Select Atlease one Row for "+act+"!");
				return false;
			}
	}

	//--- make it popular ----/
	AddTo=function (table,act,page) {
		var checked = $("input[@id=chk]:checked").length;
			if(checked >0) {
				var answer = confirm('Are You Sure You Want To '+act+'?');
				if(answer) {
					$('#myform').attr('action','control/product_insert.php?tablename='+table+'&page='+page+'&act='+act);
					$('#myform').submit();
				} else {
					return false;
				}
			} else {
				jAlert("Please Select Atlease one Row for "+act+"!");
				return false;
			}
	}
	// --- end ------//
	
	//--- purpose to dispaly city --//
	GetCity=function() {
		var nm="citys";
		var ids=$("#zone_id").attr("value");
		$.ajax({
			type:"POST",
			url:"control/insert.php",
			data:"act=GetCity&id="+ids,
				success: function(msg){
				$("#city_segment").show("slow");
				document.getElementById('city_segment').innerHTML = msg;
				//$("#sub_segment").html();	
				
				return false;
			}
		});
	};
	// -- end function -- //
	//--- purpose to dispaly products --//
	GetProduct=function() {
		var ids=$("#segment_master_id").attr("value");
		var idsu=$("#subsegment_master_id").attr("value");
		$.ajax({
			type:"POST",
			url:"control/insert.php",
			data:"act=GetProduct&ids="+ids+"&idsu="+idsu,
				success: function(msg){
				$("#product_segment").show("slow");
				document.getElementById('product_segment').innerHTML = msg;
				//$("#sub_segment").html();	
				
				return false;
			}
		});
	};
	// -- end function -- //
	// -- For get id sub_segment_master function -- //
	GetsubSegmentId=function(ids) {
		$.ajax({
			type:"POST",
			url:"control/idfind_control.php",
			data:"act=GetSubSegmentId&id="+ids,
				success: function(msg){
				document.getElementById('subsegment_div').innerHTML = msg;
				document.getElementById('segment_div_id').innerHTML = ids;
				//$("#sub_segment").html();	
				GetCategoryId(ids,'');
				GetBrandId(ids,'');
				GetTypeId(ids,'');
				return false;
			}
		});
	};

	// -- For get id category_master function -- //
	GetCategoryId=function(id,sid) {
		$.ajax({
			type:"POST",
			url:"control/idfind_control.php",
			data:"act=GetCategoryId&id="+id+"&sid="+sid,
				success: function(msg){
				document.getElementById('category_div').innerHTML = msg;
				document.getElementById('subsegment_div_id').innerHTML = sid;
				//$("#sub_segment").html();	
				GetBrandId(id,sid);
				GetTypeId(id,sid);
				return false;
			}
		});
	};
	// -- For get id category_master function -- //
	GetSubCategoryId=function(ids) {
		$.ajax({
			type:"POST",
			url:"control/idfind_control.php",
			data:"act=GetSubCategoryId&id="+ids,
				success: function(msg){
				document.getElementById('subcategory_div').innerHTML = msg;
				document.getElementById('category_div_id').innerHTML = ids;
				//$("#sub_segment").html();	
				
				return false;
			}
		});
	};
	GetSubCategoryMasterId=function(ids) {
		document.getElementById('subcategory_div_id').innerHTML = ids;
	};

	// -- For get brand_master function -- //
	GetBrandId=function(id,sid) {
		$.ajax({
			type:"POST",
			url:"control/idfind_control.php",
			data:"act=GetBrandId&id="+id+"&sid="+sid,
				success: function(msg){
				document.getElementById('brand_div').innerHTML = msg;
				
				//$("#sub_segment").html();	
				
				return false;
			}
		});
	};
	IncorporateBrandId=function(id) {
		document.getElementById('brand_div_id').innerHTML = id;
	}
	IncorporateTypeId=function(id) {
		document.getElementById('type_div_id').innerHTML = id;
	}
	IncorporateAuthorId=function(id) {
		document.getElementById('auhtor_div_id').innerHTML = id;
	}
	
	GetTypeId=function(id,sid) {
		$.ajax({
			type:"POST",
			url:"control/idfind_control.php",
			data:"act=GetTypeId&id="+id+"&sid="+sid,
				success: function(msg){
				document.getElementById('type_div').innerHTML = msg;
				
				//$("#sub_segment").html();	
				
				return false;
			}
		});
	};

	GetPinCode=function() {
		var pin=$("#pincode_master_id").attr("value");
		$.ajax({
			type:"POST",
			url:"control/insert.php",
			data:"act=GetPinCode&pid="+pin,
				success: function(msg){
					document.getElementById('f_status').innerHTML = msg;
					return false;
			}
		});
	};
	//--- Create Table ----/
	CreateTable=function (act,key) {
		var num=$("#number_field").attr("value");
		var status ;
		if(act == 1) {
			status='Add';
			num=parseInt(num)+1;
		} else if (act == 2) {
			status='Delete';
			num=parseInt(num)-1;
		} else {
			status='Blank';
			num=num;
		}
		$.ajax({
			type:"POST",
			url:"control/insert.php",
			data:"act=CreateTable&num="+num+"&status="+status+"&key="+key,
				success: function(msg){
				document.getElementById('draw_table').innerHTML = msg;
				$("#number_field").attr("value",num);
				return false;
			}
		});
	}
	// --- end ------//
	// --- Courier Contact Update Purpose ------//
	
		CreateTableUpdate=function(id,key) {
			var num=$("#number_field").attr("value");
			
			$.ajax({
				type:"POST",
				url:"control/insert.php",
				data:"act=CreateTableUpdate&id="+id+"&num="+num+"&key="+key,
					success: function(msg){
					$('#draw_table').html(msg);
					$("#number_field").attr("value",num);
					return false;
				}
			});
		}
		// --- Remove From Latest Book ------//
		
		// --- Insert Dyanamic Value ------//
		
		SendDynamicData=function(table,tablefield,field,domobj,status,hiderow,id) {
			jAlert(domobj);
			var val=$("#"+field).attr("value");
			$.ajax({
				type:"POST",
				url:"control/insert.php",
				data:"act=AddValueByJquery&table="+table+"&field="+tablefield+"&values="+val+"&status="+status+"&selectid="+id,
					success: function(msg){
					document.getElementById(domobj).innerHTML = msg;
					
					$("#"+hiderow).hide("slow");
					$("#"+field).attr("value","");
					
					return false;
				}
			});
		}
		
		//--------------- End ----------------------//
		//---------------Fatch table columns --------//
		GetTablesColumn=function() {			
			var val=$("#table_name").attr("value");
			$.ajax({
				type:"POST",
				url:"control/insert.php",
				data:"act=GetTableColumn&table="+val,
					success: function(msg){
					document.getElementById("div_field").innerHTML = msg;
					return false;
				}
			});
		}
		// --- Admin Products Insert By Dyanmic Text Area  ------//
		
		//---------------Fetch keyword --------//
		Fetchkeywords=function(table,div,idname) {			
			var segmentname=$("#segment").attr("value");
			var val=$("textarea#"+idname).attr("value");
			if(segmentname == '') {
				jAlert("Select segment  !");
				return false ;
			}
			if(val == '') {
				jAlert("Enter the value in text area !");
				return false ;
			}
			val = val.replace(/\n\r?/g, ',');
			$.ajax({
				type:"POST",
				url:"control/insert.php",
				data:"act=AddKeyword&tablename="+table+"&val="+val+"&idname="+idname+"&segment="+segmentname,
					success: function(msg){
					document.getElementById(div).innerHTML = msg;
					$("textarea#"+idname).attr("value"," ");
					return false;
				}
			});
		}
		
		//------------------ Delete Keyword ---------------------//
		DeleteKeyword=function (tableid,id) {
			var segmentname=$("#segment").attr("value");
			var table='';
			
			if(tableid ==1 ) {
				table='keywordbrand_master';	
			} else if(tableid ==2 ){
				table='keywordcity_master';
			} else if(tableid ==3 ){
				table='keywordcountry_master';
			} else if(tableid == 4){
				table='keywordgeneral_master';
			}else if(tableid ==5 ){
				table='keywordpost_master';
			}else if(tableid == 6){
				table='keywordpre_master';
			}

			$.ajax({
				type:"POST",
				url:"control/insert.php",
				data:"act=DeleteKeyword&tablename="+table+"&id="+id+"&segment="+segmentname,
					success: function(msg){
					document.getElementById(table).innerHTML = msg;
					return false;
				}
			});
			
			
		}
		// --- Admin Products Insert By Dyanmic Text Area  ------//
	
		InsertRocordsDynamic=function(id) {
			//jAlert($("#add_new_products").css("display"));
			if($("#"+id).css("display")== 'none' ) {
				$("#"+id).show("slow");
			} else {
				$("#"+id).hide("slow");
			}
		}
		// --- Remove From Latest Book ------//
		
		RemoveFromLatestBook=function (id,status) {
				var act='';
				var a='';
				if(status == '1')  {
					act ='LatestBook';
					a='Add to ';
				} else if (status == '2') {
					act ='RemoveFromLatestBook';
					a='Remove From ';
				}
				 
				var selector_checked = $("input[@id=chk]:checked").length;
				
				if (selector_checked == 0) { 
					$('.chk_'+id).attr('checked',true);
					var answer = confirm('Are You Sure You Want To '+a+' Latest Book?');
	   				 if (answer){
	        	   		window.location='control/insert.php?act='+act+'&id='+id;
					} else {
						$('.chk_'+id).removeAttr('checked');
						return false;
					}
				} else { 
					$('.chk_'+id).removeAttr('checked');
					return false;
				}
		}

		function CreateDatePicker(id){
			$('#'+id).datepicker({
				showOn:'both',
				buttonImage: "images/calendar.gif",
				buttonImageOnly: true
			});
		}
		
		<?php if(isset($_REQUEST["id"]) && $_REQUEST["id"] != '') {
				$pgarray=explode('?',basename($_SERVER["REQUEST_URI"]));
				if($pgarray[0]== "courier_insert_update.php") { ?>
						CreateTableUpdate(<?php echo @$_REQUEST["id"]; ?>,'');
		<?php 	} else { ?>
					CreateTableUpdate(<?php echo @$_REQUEST["id"]; ?>,'1');
		<?php 	}
		}?>
}); // -- end --//


</script>
</head>
<body>
<!--===========top content===========================-->
<div id="topheader">
  <div id="inn-logo"><img src="<?php echo MAGIC_HTTP_IMAGE_PATH ;?>" id="kbazaarlog" alt="Magic" border="0"/></div>
  <!-- inn-logo -->
  <div id="inn-top-nav">
  	Welcome , <span style="font-size: 15px; color: white;font-weight: bold;" ><?php echo ucwords(@$_SESSION["user_id"]); ?></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<a title="Home" href="index.php" >Home</a>&nbsp;|&nbsp
        <a title="Logout" href="<?php echo SITE_URL ;?>login/login/logout" >Logout</a> 
  </div>
  <!-- inn-top-nav -->
  <div class="height10"></div>
  <?php include "admin_menu.php" ?>
</div>
<!-- #topheader-->
<!--===========top content===========================-->
<div id="InnerPageDetails">